// safe-area
const { BaseBehavior, COMPONENT_OPTIONS } = require('../../mixins/component');
const { getMenuButtonBoundingClientRect } = require('../../common/platform');

Component({
    behaviors: [BaseBehavior],
    options: {
        ...COMPONENT_OPTIONS,
    },
    properties: {
        // 是否包含顶部导航栏
        containsHeader: {
            type: Boolean,
            value: false,
        },
    },
    data: {
        styleValue: '',
    },
    lifetimes: {
        // 生命周期函数，可以为函数，或一个在methods段中定义的方法名
        attached: function () {
            const obj = getMenuButtonBoundingClientRect();
            const { containsHeader } = this.data;
            this.setData({
                styleValue: `height: ${containsHeader ? obj.bottom : obj.top}px;`,
            });
        },
    },
})